const { Schema, SchemaTypes } = require('../schema');
const CreditRecordStatus = require('../../module/const/CreditRecordStatus');
class CreditRecord extends Schema {
    PropertyModelDataTemplate () {
        return {
            userId: {
                type: SchemaTypes.ObjectId,
                required: true
            },
            areaId: {
                type: SchemaTypes.ObjectId,
                required: true
            },
            orderId: {
                type: SchemaTypes.ObjectId,
                required: true
            },
            // (单位：元)
            useAmount: {
                type: SchemaTypes.Number,
                required: true,
                comment: '已使用信用金'
            },
            // (单位：元)
            repaymentAmount: {
                type: SchemaTypes.Number,
                required: false
            },
            repaymentTime: {
                type: SchemaTypes.Number,
                required: false
            },
            status: {
                type: SchemaTypes.Number,
                required: true,
                default: CreditRecordStatus.Payed.value
            },
            cancelTime: {
                type: SchemaTypes.Number,
                required: false
            },

            prepayId: {
                type: SchemaTypes.String,
                required: false,
                comment: '微信支付预支付id'
            },
            paymentOrderId: {
                type: SchemaTypes.String,
                required: false,
                comment: '支付id'
            },
            createTime: {
                type: SchemaTypes.Number,
                required: true,
                default: require('../../module/tool/time').getCurrentTimestamp()
            }
        };
    }
}

module.exports = CreditRecord;
